<template>
  <a-row :gutter="10">
      <a-card :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">
              <a-col :md="4" :sm="6">
                <a-form-item :label="$t('light.lightCode')">
                  <j-input :placeholder="$t('base.inputVagueQuery')" v-model="queryParam.ligCode"></j-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="4">
                <a-form-item :label="$t('base.createTime')">
                  <a-range-picker
                    style="width: 210px"
                    v-model="queryParam.createTimeRange"
                    format="YYYY-MM-DD"
                    :placeholder="[$t('base.startTime'), $t('base.endTime') ]"
                    @change="onDateChange"
                  />
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search"> {{$t('base.query')}} </a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px"> {{$t('base.reset')}} </a-button>
            </span>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <!-- 查询区域-END -->


        <!-- table区域-begin -->
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            :rowSelection="{fixed:true,selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"

            @change="handleTableChange">

            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
              <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
              <a-button
                v-else
                :ghost="true"
                type="primary"
                icon="download"
                size="small"
                @click="uploadFile(text)">
                下载
              </a-button>
            </template>

            <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
              <a-menu-item>
                <a @click="updateLg(record)">修改经纬度</a>
              </a-menu-item>

            </a-menu>
          </a-dropdown>
        </span>

          </a-table>
        </div>

        <glrLight-modal ref="modalForm" @ok="modalFormOk"></glrLight-modal>
      </a-card>
  </a-row>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import GlrLightModal from './modules/GlrLightModal'
  import { filterObj } from '@/utils/util';
  import JInput from '@/components/jeecg/JInput'
  import JDate from '@/components/jeecg/JDate'
  export default {
    name: "GlrSideLightCurrentList",
    mixins:[JeecgListMixin],
    props:['gateWayCode'],
    components: {
      GlrLightModal,
      JInput,
      JDate
    },
    data () {
      return {
        description: '路灯管理管理页面',
        dropTrigger: '',
        autoExpandParent:true,
        defaultExpandParent:true,
        iExpandedKeys:[],
        gateWayCode:'',
        queryParam: {
            createTimeRange:[],
        },
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:this.$t('light.lightCode'),
            align:"center",
            dataIndex: 'ligCode'
          },
          {
              title:this.$t('light.gateWayCode') ,
              align:"center",
              dataIndex: 'gataWayCode'
          },
          {
              title:this.$t('light.gateWay') ,
              align:"center",
              dataIndex: 'gateWayName'
          },
          {
            title:this.$t('light.voltageV') ,
            align:"center",
            dataIndex: 'currentVol'
          },
          {
            title:this.$t('light.currentMa') ,
            align:"center",
            dataIndex: 'currentCur'
          },
          {
            title:this.$t('light.brightnessPCT') ,
            align:"center",
            dataIndex: 'currentBrightness'
          },
          {
            title: this.$t('light.currentPowerW') ,
            align:"center",
            dataIndex: 'currentPower'
          },
          {
            title:this.$t('light.currentApparentPowerW') ,
            align:"center",
            dataIndex: 'currentApparentPower'
          },
          {
            title:this.$t('light.temperatureDw') ,
            align:"center",
            dataIndex: 'currentTemperature'
          },
          {
            title:this.$t('light.returnTime'),
            align:"center",
            dataIndex: 'createTime'
          },
        ],
        url: {
          list: "/glr/glrLightCurrent/list",
          delete: "/glr/glrLight/delete",
          deleteBatch: "/glr/glrLight/deleteBatch",
          exportXlsUrl: "/glr/glrLight/exportXls",
          importExcelUrl: "glr/glrLight/importExcel",

        },
        dictOptions:{
        },
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    watch: {
      gateWayCode: {
        immediate: true,
        handler(valData) {
          this.queryParam.gataWayCode=valData;
          this.loadData();
        }
      },
    },
    created(){

    },
    methods: {
      initDictConfig(){
      },
      onDateChange: function (value, dateString) {
          console.log(dateString[0],dateString[1]);
          this.queryParam.createTime_begin=dateString[0];
          this.queryParam.createTime_end=dateString[1];
      },
      getQueryParams(){
          var param = Object.assign({}, this.queryParam,this.isorter);
          param.field = this.getQueryField();
          param.pageNo = this.ipagination.current;
          param.pageSize = this.ipagination.pageSize;
          delete param.createTimeRange; // 时间参数不传递后台
          if (this.superQueryParams) {
              param['superQueryParams'] = encodeURI(this.superQueryParams)
              param['superQueryMatchType'] = this.superQueryMatchType
          }
          return filterObj(param);
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>